package com.tensquare.search.service;

import com.tensquare.search.dao.ArticleDao;
import com.tensquare.search.pojo.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import util.IdWorker;

/**
 * Created by WF on 2020/4/1 15:13
 */
@Service
public class ArticleService {
    @Autowired
    private IdWorker idWorker;
    @Autowired
    private ArticleDao articleDao;
    //1.添加索引
    public void add(Article article) {
        //1.1 生成主键
        long nextId = idWorker.nextId();
        //1.2 添加主键
        article.setId(nextId + "");
        //1.3 添加索引
        articleDao.save(article);
    }
}
